/*
 * @Description: 
 * @Author: 马爽
 * @Date: 2021-03-08 23:21:32
 * @LastEditTime: 2021-03-09 08:41:35
 * @LastEditors: 马爽
 */

import React, { FC } from 'react';
import { useDispatch } from 'umi';
import { Button, Input, Select, Form} from 'antd';

const { Option } = Select;

const layout = {
  labelCol: { span: 8 },
  wrapperCol: { span: 16 },
};

const tailLayout = {
  wrapperCol: { offset: 1, span: 16 },
};


const Addidentity:FC = () => {
    const dispatch = useDispatch();
    
    const [form] = Form.useForm();

    const onReset = () => {
        form.resetFields();
    };
        
    const onFinish = (values: any) => {
        console.log('Success:', values);
        //是否成功 
        dispatch({
            type:'userManage/AddIdentity',
            payload:{...values}
        })
    };

    return (
        <div className='addbox'>
          <div className='btn'>
            <Button>添加身份</Button>
          </div>
          <Form
            form={form}
            {...layout}
            name="basic"
            onFinish={onFinish}
          >

            <Form.Item
              name="identity_text"
              rules={[{ required: true, message: '身份名称' }]}
            >
              <Input placeholder='请输入身份名称' />
            </Form.Item>

            <Form.Item {...tailLayout}>
              <Button type="primary" htmlType="submit">
                确定
              </Button>
              <Button htmlType="button" onClick={onReset}>
                重置
              </Button>
            </Form.Item>
          </Form>
        </div>
    )
}

export default Addidentity;
